<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace vipapis\xstore\cc\transferring\api;

class SyncTransferItemOutQtyReq {
	
	static $_TSPEC;
	public $transferOrderNo = null;
	public $deliveryDate = null;
	public $shipWarehouseCode = null;
	public $transferOutItems = null;
	public $carrierCode = null;
	public $carrierName = null;
	public $transportNo = null;
	public $totalRow = null;
	public $containerCount = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'transferOrderNo'
			),
			2 => array(
			'var' => 'deliveryDate'
			),
			3 => array(
			'var' => 'shipWarehouseCode'
			),
			4 => array(
			'var' => 'transferOutItems'
			),
			5 => array(
			'var' => 'carrierCode'
			),
			6 => array(
			'var' => 'carrierName'
			),
			7 => array(
			'var' => 'transportNo'
			),
			8 => array(
			'var' => 'totalRow'
			),
			9 => array(
			'var' => 'containerCount'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['transferOrderNo'])){
				
				$this->transferOrderNo = $vals['transferOrderNo'];
			}
			
			
			if (isset($vals['deliveryDate'])){
				
				$this->deliveryDate = $vals['deliveryDate'];
			}
			
			
			if (isset($vals['shipWarehouseCode'])){
				
				$this->shipWarehouseCode = $vals['shipWarehouseCode'];
			}
			
			
			if (isset($vals['transferOutItems'])){
				
				$this->transferOutItems = $vals['transferOutItems'];
			}
			
			
			if (isset($vals['carrierCode'])){
				
				$this->carrierCode = $vals['carrierCode'];
			}
			
			
			if (isset($vals['carrierName'])){
				
				$this->carrierName = $vals['carrierName'];
			}
			
			
			if (isset($vals['transportNo'])){
				
				$this->transportNo = $vals['transportNo'];
			}
			
			
			if (isset($vals['totalRow'])){
				
				$this->totalRow = $vals['totalRow'];
			}
			
			
			if (isset($vals['containerCount'])){
				
				$this->containerCount = $vals['containerCount'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'SyncTransferItemOutQtyReq';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("transferOrderNo" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->transferOrderNo);
				
			}
			
			
			
			
			if ("deliveryDate" == $schemeField){
				
				$needSkip = false;
				$input->readI64($this->deliveryDate);
				
			}
			
			
			
			
			if ("shipWarehouseCode" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->shipWarehouseCode);
				
			}
			
			
			
			
			if ("transferOutItems" == $schemeField){
				
				$needSkip = false;
				
				$this->transferOutItems = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						
						$elem0 = new \vipapis\xstore\cc\transferring\api\TransferOutItem();
						$elem0->read($input);
						
						$this->transferOutItems[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("carrierCode" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->carrierCode);
				
			}
			
			
			
			
			if ("carrierName" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->carrierName);
				
			}
			
			
			
			
			if ("transportNo" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->transportNo);
				
			}
			
			
			
			
			if ("totalRow" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->totalRow); 
				
			}
			
			
			
			
			if ("containerCount" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->containerCount); 
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		$xfer += $output->writeFieldBegin('transferOrderNo');
		$xfer += $output->writeString($this->transferOrderNo);
		
		$xfer += $output->writeFieldEnd();
		
		if($this->deliveryDate !== null) {
			
			$xfer += $output->writeFieldBegin('deliveryDate');
			$xfer += $output->writeI64($this->deliveryDate);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->shipWarehouseCode !== null) {
			
			$xfer += $output->writeFieldBegin('shipWarehouseCode');
			$xfer += $output->writeString($this->shipWarehouseCode);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->transferOutItems !== null) {
			
			$xfer += $output->writeFieldBegin('transferOutItems');
			
			if (!is_array($this->transferOutItems)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->transferOutItems as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->carrierCode !== null) {
			
			$xfer += $output->writeFieldBegin('carrierCode');
			$xfer += $output->writeString($this->carrierCode);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->carrierName !== null) {
			
			$xfer += $output->writeFieldBegin('carrierName');
			$xfer += $output->writeString($this->carrierName);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->transportNo !== null) {
			
			$xfer += $output->writeFieldBegin('transportNo');
			$xfer += $output->writeString($this->transportNo);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->totalRow !== null) {
			
			$xfer += $output->writeFieldBegin('totalRow');
			$xfer += $output->writeI32($this->totalRow);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->containerCount !== null) {
			
			$xfer += $output->writeFieldBegin('containerCount');
			$xfer += $output->writeI32($this->containerCount);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>